package implementor;

import java.sql.SQLException;

import dao.ProjectDao;
import dbhandelling.Crude;

import dto.Project;

public class ProjectImpl extends Crude implements ProjectDao{

	String className=new Project().getClass().getName();
	@Override
	public void add(Project proj) throws SQLException, Exception {
		super.insert(proj);
		
	}

	@Override
	public void update(Project proj) throws Exception {
		super.update(className,"projectName",proj.getProjectName(), "autoIdProject", proj.getAutoIdProject()+"");
		super.update(className,"projectStatus",proj.getProjectStatus()+"", "autoIdProject", proj.getAutoIdProject()+"");
	}

	@Override
	public void delete(Project proj) throws Exception {
		super.delete(className,"autoIdProject", proj.getAutoIdProject()+"");
		
	}

	@Override
	public Project retreive(String conditionField, String ConditionValue)
			throws Exception {
		Project p=(Project) super.retreive( className,conditionField, ConditionValue);
		return p;
	}

	@Override
	public Project[] retreiveArray(String conditionField, String ConditionValue)
			throws Exception {
		Object[] prjct= super.retreiveArrayOnCondition(className, conditionField, ConditionValue);
		Project[] s=new Project[prjct.length];
		
		for(int i=0;i<s.length;i++)
			s[i]=(Project) prjct[i];
		return s;
	}

	@Override
	public Project[] retreiveAll() throws Exception {
		Object[] prjct= super.retreiveAll(className);
		Project[] s=new Project[prjct.length];
		
		for(int i=0;i<s.length;i++)
			s[i]=(Project) prjct[i];
		return s;
	}

}
